<?php
global $_GPC, $_W;
$GLOBALS['frames'] = $this->getMainMenu();
$item = pdo_get('yzzc_sun_store_config', ['uniacid' => $_W['uniacid']]);
global $_W, $_GPC;

if (checksubmit('submit')) {
    $data = [
        'is_open_apply' => $_GPC['is_open_apply'],
        'is_fee' => $_GPC['is_fee'],
        'amount' => $_GPC['amount'],
        'platform_fee' => $_GPC['platform_fee'],
        'payout_fee' => $_GPC['payout_fee'],
        'content' => $_GPC['content'],
        'member_rule' => $_GPC['member_rule'],
        'uniacid' => $_W['uniacid'],
        'updatetime' => time()
    ];
    $result = pdo_update('yzzc_sun_store_config', $data, ['id' => $_GPC['id'], 'uniacid' => $_W['uniacid']]);
    if ($result) {
        message('操作成功', $this->createWebUrl('storeconfig', array()), 'success');
    } else {
        message('操作失败', $this->createWebUrl('storeconfig', array()), 'error');
    }
}

include $this->template('web/store/store_config');pager = pagination($total, $page, $size);
global $_W, $_GPC;

if($_GPC['op']=='delete'){
    $is=pdo_get('yzzc_sun_goods',array('sid'=>$_GPC['id']));
    if($is){
        message('请先至车辆列表下架所有车辆才能删除','','error');
    }else{
        $res=pdo_delete('yzzc_sun_branch',array('id'=>$_GPC['id']));
        if($res){
            message('操作成功',$this->createWebUrl('branchslist',array()),'success');
        }else{
            message('操作失败','','error');
        }

    }

}
if($_GPC['op']=='change'){
    $where = ['store_id'=>$_GPC['id']];
    $store_info=pdo_get('yzzc_sun_store',$where);
    if ($store_info['status'] == $_GPC['status']){
        message('状态错误，修改失败',$this->createWebUrl('storelist',array()),'error');
    }

    $data = ['status'=>$_GPC['status']];
    if (isset($_GPC['remark']) && $_GPC['remark']){
        $data['remark'] = $_GPC['remark'];
    }

    $res=pdo_update('yzzc_sun_store',$data,$where);
    if($res){
        message('操作成功',$this->createWebUrl('storelist',array()),'success');
    }else{
        message('操作失败','','error');
    }
}

include $this->template('web/store_list');